Page({
    data: {
        result: null,
        imagex: null,
        drawimgDone: !1,
        painting: {},
        shareImage: "",
        sex: "汉子",
        guaiwu: "正常人",
        biaoqing: "面露凶相",
        sharemsg: "",
        beauty: 80,
        chaoguo: 0
    },
    onLoad: function(t) {
        t.result ? this.setData({
            result: t.result,
            imagex: t.image
        }) : (console.log(t), this.setData({
            chaoguo: 97.1541,
            result: {
                beauty: 94
            },
            drawimgDone: !0,
            imgheight: 1,
            imgwidth: 1,
            shareImage: "https://alanxrhuang-89c2c8.tcb.qcloud.la/WechatIMG499.png"
        })), console.log("加载成功，图片为：" + this.data.imagex), console.log("加载成功，结果为："), console.log(this.data.result), 
        "" == this.data.shareImage && this.getimai(this.data.imagex);
    },
    onShow: function() {
        "" == this.data.shareImage && this.jisiam();
    },
    onReady: function() {
        console.log(111111111);
        console.log(this.data.imgwidth), console.log(this.data.imgheight), console.log(this.data.imgtop), 
        console.log(this.data.imgleft), "" == this.data.shareImage && this.eventDraw();
    },
    jisiam: function() {
        var t = this;
        console.log(33333333);
        console.log(t.data.result);
        
        t.data.result <= 100 ? t.setData({
            beauty: parseInt(t.data.result) + 5,
            chaoguo: parseInt(1.0121 * (parseInt(t.data.result) + 5 + .3321 * (100 - parseInt(t.data.result) - 5)) * 1e4) / 1e4
        }) : t.setData({
            beauty: 100,
            chaoguo: 99.9999
        }),
        console.log(4444444);
        console.log(t.data.chaoguo);
        console.log(t.data.beauty);
        t.data.chaoguo >= 100 && t.setData({
            chaoguo: 99.9999
        }), t.data.beauty >= 100 && t.setData({
            beauty: 100
        });
         //, this.data.result.gender < 50 && this.setData({
        //     sex: "妹子"
        // }), this.data.result.expression < 10 ? this.setData({
        //     biaoqing: "满脸不爽"
        // }) : this.data.result.expression < 20 ? this.setData({
        //     biaoqing: "略带忧愁"
        // }) : this.data.result.expression < 30 ? this.setData({
        //     biaoqing: "似笑非笑"
        // }) : this.data.result.expression < 40 ? this.setData({
        //     biaoqing: "面带微笑"
        // }) : this.data.result.expression < 50 ? this.setData({
        //     biaoqing: "笑中带泪"
        // }) : this.data.result.expression < 60 ? this.setData({
        //     biaoqing: "笑里藏刀"
        // }) : this.data.result.expression < 70 ? this.setData({
        //     biaoqing: "双眼放光"
        // }) : this.data.result.expression < 80 ? this.setData({
        //     biaoqing: "面露杀气"
        // }) : this.data.result.expression < 90 ? this.setData({
        //     biaoqing: "花枝招展"
        // }) : this.data.result.expression < 100 ? this.setData({
        //     biaoqing: "笑得妖娆"
        // }) : this.setData({
        //     biaoqing: "倾城一笑"
        // });
    },
    getimai: function(t) {
        console.log(22222222);
        console.log(t);
        var a = this;
        wx.getImageInfo({
            src: t,
            success: function(t) {
                var e = 340 / (t.width / t.height);
                if ((s = 446.5 - (e + 17.5)) < 0) var s = 0;
                a.setData({
                    imgleft: 17.5,
                    imgtop: 17.5,
                    imgwidth: 340,
                    imgheight: e,
                    ajust: s
                });
            }
        });
    },
    eventDraw: function() {
        var t = this;
        console.log("开始绘制"), wx.showLoading({
            title: "绘制分享图片中",
            mask: !0
        }), t.setData({
            painting: {
                width: 375,
                height: 555 - t.data.ajust,
                background: "#FFFFFF",
                clear: !0,
                views: [ {
                    type: "image",
                    url: "/assets/sx.png",
                    top: 0,
                    left: 0,
                    width: 375,
                    height: 555 - t.data.ajust
                }, {
                    type: "image",
                    url: t.data.imagex,
                    top: t.data.imgtop,
                    left: t.data.imgleft,
                    width: t.data.imgwidth,
                    height: t.data.imgheight
                }, {
                    type: "image",
                    url: "https://api.mlito.com/yz/pic_info1.png",
                    top: 446.5 - t.data.ajust,
                    left: 0,
                    width: 375,
                    height: 108.5
                }, {
                    type: "text",
                    content: t.data.beauty,
                    fontSize: 48,
                    color: "#fa686f",
                    textAlign: "center",
                    top: 456.5 - t.data.ajust,
                    left: 285
                }, {
                    type: "text",
                    content: "超过了全中国" + t.data.chaoguo + "%的用户",
                    fontSize: 15,
                    color: "#717171",
                    textAlign: "left",
                    top: 511.5 - t.data.ajust,
                    left: 111
                } ]
            }
        });
    },
    previewshare: function() {
        wx.previewImage({
            current: "",
            urls: [ this.data.shareImage ],
            success: function(t) {},
            fail: function(t) {},
            complete: function(t) {}
        });
    },
    saveshare: function() {
        wx.saveImageToPhotosAlbum({
            filePath: this.data.shareImage,
            success: function(t) {
                wx.showModal({
                    title: "保存成功",
                    content: "图片已保存到相册，记得去朋友圈分享哦～",
                    confirmText: "好哒"
                });
            },
            fail: function(t) {},
            complete: function(t) {}
        });
    },
    eventSave: function() {
        wx.saveImageToPhotosAlbum({
            filePath: this.data.shareImage,
            success: function(t) {
                "saveImageToPhotosAlbum:ok" === t.errMsg && (wx.showToast({
                    title: "保存图片成功",
                    icon: "success",
                    duration: 2e3
                }), console.log(t));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    jumptoindex: function() {
        wx.redirectTo({
            url: "index"
        });
    },
    eventGetImage: function(t) {
        console.log(t), wx.hideLoading();
        var a = t.detail, e = a.tempFilePath;
        "canvasdrawer:ok" === a.errMsg && (this.setData({
            shareImage: e,
            drawimgDone: !0
        }), wx.getImageInfo({
            src: e,
            success: function(t) {
                console.log(t.width, t.height);
            }
        }), console.log(this.data.shareImage));
    },
    onShareAppMessage: function(t) {
        return "button" === t.from && console.log(t.target), {
            title: "@我：我测出颜值" + this.data.beauty + "分，超过" + this.data.chaoguo + "%的用户，你也来试试吧！",
            path: "pages/index/index",
            imageUrl: this.data.shareImage
        };
    },
    clickshare: function(t) {
        this.onShareAppMessage;
    },
    paytome: function() {
        var t = [ "" ];
        wx.previewImage({
            urls: t,
            success: function(t) {}
        });
    },
    addme: function() {
        var t = [ "" ];
        wx.previewImage({
            urls: t,
            success: function(t) {}
        });
    },
    jumptomini: function() {
        wx.navigateToMiniProgram({
            appId: "wxb7bd570e227528c6",
            extraData: {
                from: "youtu"
            },
            success: function(t) {
                wx.reportAnalytics("jumptoxiaobin", {
                    start: "1",
                    end: "1"
                });
            },
            fail: function(t) {
                console.log(t), wx.reportAnalytics("jumptoxiaobin", {
                    start: "1",
                    end: "0"
                });
            }
        });
    }
});